Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow JLine to fall back to a dumb terminal #21330

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Aug 5, 2024

Set the dumb JLine option to null instead of false when a dumb terminal is not forced. This allows JLine to fall back to a dumb terminal if needed.

Fixes #11978.

Before:

➜ ~/dotty git:(mb/11978) ✗ echo 'object Example { def smth = "smth" }' | bin/scala
The `--offline` option is experimental
Please bear in mind that non-ideal user experience should be expected.
If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
Exception in thread "main" java.lang.IllegalStateException: Unable to create a terminal
        at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:394)
        at org.jline.terminal.TerminalBuilder.build(TerminalBuilder.java:362)
        at dotty.tools.repl.JLineTerminal.<init>(JLineTerminal.scala:34)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:145)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:136)
        at dotty.tools.repl.Main$.main(Main.scala:7)
        at dotty.tools.repl.Main.main(Main.scala)
        Suppressed: java.io.IOException: Unable to find terminal provider ffm
                at org.jline.terminal.spi.TerminalProvider.load(TerminalProvider.java:74)
                at org.jline.terminal.TerminalBuilder.checkProvider(TerminalBuilder.java:667)
                at org.jline.terminal.TerminalBuilder.getProviders(TerminalBuilder.java:632)
                at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:395)
                ... 6 more
        Suppressed: java.io.IOException: Unable to find terminal provider jni
                at org.jline.terminal.spi.TerminalProvider.load(TerminalProvider.java:74)
                at org.jline.terminal.TerminalBuilder.checkProvider(TerminalBuilder.java:667)
                at org.jline.terminal.TerminalBuilder.getProviders(TerminalBuilder.java:634)
                at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:395)
                ... 6 more
        Suppressed: java.io.IOException: Unable to find terminal provider jansi
                at org.jline.terminal.spi.TerminalProvider.load(TerminalProvider.java:74)
                at org.jline.terminal.TerminalBuilder.checkProvider(TerminalBuilder.java:667)
                at org.jline.terminal.TerminalBuilder.getProviders(TerminalBuilder.java:636)
                at org.jline.terminal.TerminalBuilder.doBuild(TerminalBuilder.java:395)
                ... 6 more

After:

➜  ~/dotty git:(mb/11978) echo 'object Example { def smth = "smth" }' | bin/scala
The `--offline` option is experimental
Please bear in mind that non-ideal user experience should be expected.
If you encounter any bugs or have feedback to share, make sure to reach out to the maintenance team at https://github.com/VirtusLab/scala-cli
Aug 05, 2024 3:53:49 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Welcome to Scala 3.6.0-RC1-bin-SNAPSHOT-git-dce4377 (17.0.8, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> // defined object Example

scala> %                                                                                                                         
➜  ~/dotty 

@SethTisue SethTisue changed the title Allow JLine to fall back to a dump terminal Allow JLine to fall back to a dumb terminal Aug 6, 2024
Set the `dumb` JLine option to `null` instead of `false` when it is not forced. This allows JLine to fall back to a dumb terminal.

Also adapt `CoursierScalaTests` accordingly: test that the `scala` command executes commands fed through standard input correctly.
@mbovel
Copy link
Member Author

mbovel commented Aug 6, 2024

@smarter: that's an implementation of what you suggested in #11707 (comment).

@mbovel mbovel requested a review from smarter August 6, 2024 12:49
@smarter smarter enabled auto-merge August 6, 2024 13:03
@smarter smarter merged commit bad02ab into scala:main Aug 6, 2024
26 checks passed
@mbovel mbovel deleted the mb/11978 branch August 6, 2024 13:40
WojciechMazur added a commit that referenced this pull request Aug 28, 2024
Backports #21330 to the 3.5.2 branch.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added this to the 3.5.2 milestone Oct 8, 2024
WojciechMazur added a commit that referenced this pull request Dec 3, 2024
Backports #21330 to the 3.3.5.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JLine error when attempting to run the REPL with piped input
3 participants